package com.hjm.project.actTransactionCompliance.compliance.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.project.actTransactionCompliance.compliance.domain.ActTransactionCompliance;
import com.hjm.project.actTransactionCompliance.compliance.service.IActTransactionComplianceService;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import com.hjm.framework.web.page.TableDataInfo;

/**
 * 交易额返现阶梯Controller
 * 
 * @author LOVE
 * @date 2020-11-29
 */
@Controller
@RequestMapping("/actTransactionCompliance/compliance")
public class ActTransactionComplianceController extends BaseController
{
    private String prefix = "actTransactionCompliance/compliance";

    @Autowired
    private IActTransactionComplianceService actTransactionComplianceService;

    @RequiresPermissions("actTransactionCompliance:compliance:view")
    @GetMapping()
    public String compliance()
    {
        return prefix + "/compliance";
    }

    /**
     * 查询交易额返现阶梯列表
     */
    @RequiresPermissions("actTransactionCompliance:compliance:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ActTransactionCompliance actTransactionCompliance)
    {
        startPage();
        List<ActTransactionCompliance> list = actTransactionComplianceService.selectActTransactionComplianceList(actTransactionCompliance);
        return getDataTable(list);
    }

    /**
     * 导出交易额返现阶梯列表
     */
    @RequiresPermissions("actTransactionCompliance:compliance:export")
    @Log(title = "交易额返现阶梯", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ActTransactionCompliance actTransactionCompliance)
    {
        List<ActTransactionCompliance> list = actTransactionComplianceService.selectActTransactionComplianceList(actTransactionCompliance);
        ExcelUtil<ActTransactionCompliance> util = new ExcelUtil<ActTransactionCompliance>(ActTransactionCompliance.class);
        return util.exportExcel(list, "compliance");
    }

    /**
     * 新增交易额返现阶梯
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存交易额返现阶梯
     */
    @RequiresPermissions("actTransactionCompliance:compliance:add")
    @Log(title = "交易额返现阶梯", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ActTransactionCompliance actTransactionCompliance)
    {
        return toAjax(actTransactionComplianceService.insertActTransactionCompliance(actTransactionCompliance));
    }

    /**
     * 修改交易额返现阶梯
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ActTransactionCompliance actTransactionCompliance = actTransactionComplianceService.selectActTransactionComplianceById(id);
        mmap.put("actTransactionCompliance", actTransactionCompliance);
        return prefix + "/edit";
    }

    /**
     * 修改保存交易额返现阶梯
     */
    @RequiresPermissions("actTransactionCompliance:compliance:edit")
    @Log(title = "交易额返现阶梯", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ActTransactionCompliance actTransactionCompliance)
    {
        return toAjax(actTransactionComplianceService.updateActTransactionCompliance(actTransactionCompliance));
    }

    /**
     * 删除交易额返现阶梯
     */
    @RequiresPermissions("actTransactionCompliance:compliance:remove")
    @Log(title = "交易额返现阶梯", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(actTransactionComplianceService.deleteActTransactionComplianceByIds(ids));
    }
}
